<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var newData = {}// computed
    var data = "呵呵哒"// data=>{}
    // 核心的数据监听
    Object.defineProperty(newData, "name", {
      get() {
        console.log("获取值")
        return data
      },
      set(value) {
        console.log("设置值", value);
        data = value;
      }
    });

    // 设置值
    newData.name = "123456"
    // 获取值
    console.log(newData.name)

  </script>
</body>

</html>